#include "guiterm.hpp"
#ifndef FILETRANSFERVIEW_HPP
#define FILETRANSFERVIEW_HPP
#include "RPC.hpp"
#include <QFrame>
#include <QProgressBar>
#include <QPushButton>
#include <QFileDialog>

class FileTransferView
	:public JobViewSegment
{
	Q_OBJECT
public:
	FileTransferView(RemoteJob *owner, FileTransfer *transfer);
	~FileTransferView();
	
protected slots:
	void begin();
	void cancel();
	void togglePaused();
	void browse();
	void browseDialogPicked(QString dir);
	
	void listReady(const vector<string> &files);
	void transferBegun();
	void fileBegun(string file);
	void updateProgress(string filename, double progress);
	void fileFailed(string filename, string message);
	void fileFinished(string filename);
	void transferFinished(bool successful, string message);
	
protected:
	void setLocationLineDisabled(bool disabled);
	
	FileTransfer *transfer;
	
	QVBoxLayout *frameLayout;
	
	QLayout *destLineLayout;
	QLabel *destLineLabel;
	QLineEdit *destLocationEdit;
	QFileDialog *browseDialog;
	QPushButton *browseButton;
	
	QHBoxLayout *statusLineLayout;
	QLabel *statusLabel;
	QPushButton *pauseButton;
	QPushButton *cancelTransferButton;
	
	QHBoxLayout *actionsLineLayout;
	QPushButton *okButton;
	QPushButton *cancelButton;
	
	QVBoxLayout *progressLayout;
	
	struct ProgressLine {
		QLayout *layout;
		QLabel *label;
		QProgressBar *progress;
	};
	vector<ProgressLine*> lines;
};
#define FILETRANSFER_PROGRESS_MAX 10000

#endif
